package us.icitap.cm.business.entities;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.eclipse.persistence.annotations.Customizer;

import us.icitap.cm.utils.MyCustomizer;

@Entity
@Customizer(MyCustomizer.class)
@Table(name="ENTITY_ENTITY_ASSOC", schema="MPC")
@IdClass(EntityEntityAssocId.class)
public class EntityEntityAssociation implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2020358202629818363L;

	@Id
	@Column(name="REPORT_ID", insertable=false, updatable=false)
	private Integer reportId;
	

	@Id
	@Column(name="ENTITY_ONE_ID", insertable=false, updatable=false)
	private Integer entityOneId;
	
	@Id
	@Column(name="ENTITY_TWO_ID", insertable=false, updatable=false)
	private Integer entityTwoId;
	
	@Id
	@Column(name="ASSOCIATION_TYPE_ID", insertable=false, updatable=false)
	private Integer associationTypeId;
	

	@ManyToOne
	@JoinColumn(name="ENTITY_ONE_ID")
	private AppEntity entityOne;
	
	@ManyToOne
	@JoinColumn(name="ASSOCIATION_TYPE_ID")
	private AssociationType associationType;
	
	
	@ManyToOne
	@JoinColumn(name="ENTITY_TWO_ID")
	private AppEntity entityTwo;
	
	@ManyToOne
	@JoinColumn(name="REPORT_ID")
	private Report report;
	

	@Column(length=300)
	private String notes;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="RECORD_DATE")
	private Date recordDate;
	
	@Column(name="RECORD_USER", length=60)
	private String recordUser;
	

	public AppEntity getEntityOne() {
		return entityOne;
	}

	public void setEntityOne(AppEntity entityOne) {
		this.entityOne = entityOne;
	}

	public AssociationType getAssociationType() {
		return associationType;
	}

	public void setAssociationType(AssociationType associationType) {
		this.associationType = associationType;
	}

	public AppEntity getEntityTwo() {
		return entityTwo;
	}

	public void setEntityTwo(AppEntity entityTwo) {
		this.entityTwo = entityTwo;
	}


	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public Date getRecordDate() {
		return recordDate;
	}

	public void setRecordDate(Date recordDate) {
		
		this.recordDate = recordDate;
	}


	public String getRecordUser() {
		return recordUser;
	}

	public void setRecordUser(String recordUser) {
		this.recordUser = recordUser;
	}

	public Integer getReportId() {
		return reportId;
	}

	public void setReportId(Integer reportId) {
		this.reportId = reportId;
	}

	public Integer getEntityOneId() {
		return entityOneId;
	}

	public void setEntityOneId(Integer entityOneId) {
		this.entityOneId = entityOneId;
	}

	public Integer getEntityTwoId() {
		return entityTwoId;
	}

	public void setEntityTwoId(Integer entityTwoId) {
		this.entityTwoId = entityTwoId;
	}

	public Integer getAssociationTypeId() {
		return associationTypeId;
	}

	public void setAssociationTypeId(Integer associationTypeId) {
		this.associationTypeId = associationTypeId;
	}

	public Report getReport() {
		return report;
	}

	public void setReport(Report report) {
		this.report = report;
	}



	public boolean myEquals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EntityEntityAssociation other = (EntityEntityAssociation) obj;
		if (associationType == null) {
			if (other.associationType != null)
				return false;
		} else if (!associationType.equals(other.associationType))
			return false;
		if (associationTypeId == null) {
			if (other.associationTypeId != null)
				return false;
		} else if (!associationTypeId.equals(other.associationTypeId))
			return false;
		if (entityOne == null) {
			if (other.entityOne != null)
				return false;
		} else if (!entityOne.myEquals(other.entityOne))
			return false;
		if (entityTwo == null) {
			if (other.entityTwo != null)
				return false;
		} else if (!entityTwo.myEquals(other.entityTwo))
			return false;
		if (notes == null) {
			if (other.notes != null)
				return false;
		} else if (!notes.equals(other.notes))
			return false;
		return true;
	}
	
	
}
